/**
 * Created by dr2009 on 2017/2/21.
 */

const path = require('path');
const webpack = require("webpack");
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = function() {
    return {
        entry: {
            vendor: ['react', 'react-dom'],
            main: ['./app']
        },
        // output: {
        //     path: path.join(__dirname, "../dist"),
        //     filename: '[name].[chunkhash:8].js',
        //     chunkFilename: '[id].[chunkhash:8].js'
        // },
        module: {
            rules: [
                {
                    test: /\.jsx?$/,
                    use: "babel-loader",
                    include: [
                        path.resolve(__dirname, "../app")
                    ]
                }, {
                    test: /\.css/,
                    use: ["style-loader", "css-loader", 'postcss-loader']
                },{
                    test: /\.(jpg|png|gif)$/,
                    loader: 'file-loader'
                }, {
                    test: /\.(woff|woff2|eot|ttf|svg)$/,
                    loader: 'url-loader?limit=100000'
                }
            ]
        },
        devtool: "source-map",
        plugins: [
            new webpack.optimize.CommonsChunkPlugin({
                name: ["vendor", "manifest"], // vendor libs + extracted manifest
                minChunks: Infinity,
            }),

            new HtmlWebpackPlugin({
                template: './index.tpl.html',
                filename: './callback.html'
            }),
        ],
    };
};
